package com.weimei.conversionTreasure.adapter;

import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.weimei.conversionTreasure.R;

public class CBAdapter extends BaseQuickAdapter<CBAdapter.CBBean, BaseViewHolder> {
    public CBAdapter() {
        super(R.layout.item_cb);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, CBBean cbBean) {
        holder.setText(R.id.tv_cp,"产品"+(getItemPosition(cbBean)+1));

        ((EditText)holder.getView(R.id.edt_cp_unit)).addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                cbBean.setWineUnitPrice(s.toString());
            }
        });

        ((EditText)holder.getView(R.id.edt_cp_use)).addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                cbBean.setWineProductUsage(s.toString());
            }
        });

        ((EditText)holder.getView(R.id.edt_cp_cb)).addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                cbBean.setWineProductCost(s.toString());
            }
        });

    }

    public static class CBBean{
        private String WineUnitPrice;
        private String WineProductUsage;
        private String WineProductCost;

        public String getWineUnitPrice() {
            return WineUnitPrice;
        }

        public void setWineUnitPrice(String wineUnitPrice) {
            WineUnitPrice = wineUnitPrice;
        }

        public String getWineProductUsage() {
            return WineProductUsage;
        }

        public void setWineProductUsage(String wineProductUsage) {
            WineProductUsage = wineProductUsage;
        }

        public String getWineProductCost() {
            return WineProductCost;
        }

        public void setWineProductCost(String wineProductCost) {
            WineProductCost = wineProductCost;
        }
    }
}
